package org.syndicate.domain;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.syndicate.domain.SharePie;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * Abstract class for Transaction.<br/>
 * 
 * Transaction focus on money flows and how these change positions.
 * 
 * @author akiraabe
 *
 */
@RooJavaBean
@RooToString
@RooEntity
public abstract class AbstractTransaction {

	private String discriminator;
	
    @ManyToOne
    private SharePie sharePie;

    @NotNull
    @Size(min = 2)
    private String name;

    private Double amount;
    
    @Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(style = "S-")
    private Date transactionDate;
    
    /**
     * Execute transaction.
     * 
     * @return AbstractPosition that created or modified by execution.
     */
    abstract AbstractPosition execute();

}
